package com.example.hp.yuejian5.model;

import com.example.hp.yuejian5.RetrofitListener.RetrofitListener;
import com.example.hp.yuejian5.bean.CompetitionBean;
import com.example.hp.yuejian5.service.Competition_DetailService;


import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static com.example.hp.yuejian5.other.url.INDEXURL;

public class Competition_DetailModel {
    private Retrofit retrofit;
    private Competition_DetailService train_detailService;

    public Competition_DetailModel()
    {
        retrofit=new Retrofit.Builder()
                .baseUrl(INDEXURL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        train_detailService=retrofit.create(Competition_DetailService.class);
    }
    public void competitionDetail(String competition_id,final RetrofitListener listener)
    {
        Call<CompetitionBean> call=train_detailService.competitiondetail(competition_id);
        call.enqueue(new Callback<CompetitionBean>() {
            @Override
            public void onResponse(Call<CompetitionBean> call, Response<CompetitionBean> response) {
                listener.onSuccess(response.body(),1);
            }

            @Override
            public void onFailure(Call<CompetitionBean> call, Throwable t) {
                listener.onFail();
            }
        });
    }
}
